package com.scu.qingshi.infrastructure.dao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.scu.qingshi.infrastructure.dao.po.InterUserMap;
import com.scu.qingshi.infrastructure.dao.mapper.InterUserMapMapper;
import com.scu.qingshi.infrastructure.dao.service.InterUserMapService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 青时
 * @since 2022-03-05
 */
@Service
public class InterUserMapServiceImpl extends ServiceImpl<InterUserMapMapper, InterUserMap> implements InterUserMapService {

    @Override
    public InterUserMap getInterUserMap(Integer interId, Integer userId) {
        QueryWrapper<InterUserMap> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId)
                .eq("inter_id",interId);
        return baseMapper.selectOne(wrapper);
    }

    @Override
    public void iUpdate(InterUserMap map) {
        UpdateWrapper<InterUserMap> updateWrapper = new UpdateWrapper<>();
        updateWrapper.eq("map_id",map.getMapId());
        baseMapper.update(map,updateWrapper);
    }
}
